home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / archiver / ldiff12s.zip / LDE16.ASM < prev    next >
Assembly Source File  |  1989-07-15  |  9KB  |  370 lines

  1. ;-----------------------------------------------------------------------------;
  2. ; LDE16.asm Ä½Åæî┼ÆΦÄ«üiùΓôÇüj     (C) ÄOû╪ÿaòF NIFTY SDR SDI00147   1989/7/15;
  3. ;-----------------------------------------------------------------------------;
  4. ; ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@    èεû{ôIé╚âAâïâSâèâYâÇé═ë£æ║Äüé╠ébé≡ÄQÅ╞;
  5. ; ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ü@ ü@ü@ü@ü@ ì\æóë╗â}âNâìé═î├É∞Äüé╠éαé╠é≡Ägùp;
  6. ;                                          ;
  7. ;   ì∞ɼû@:                                      ;
  8. ;       optasm é≡ Use THREADs for Smaller OBJ(N) é╔é╡é─âAâZâôâuâïé╖éΘ         ;
  9. ;                                          ;
  10. ;-----------------------------------------------------------------------------;
  11. include lms3.inc                    ; ìéæ¼ì\æóë╗â}âNâì
  12.                             ; (c)S.Furukawa
  13. include minimac.inc                    ; movseg movdat movdatb
  14. ;-----------------------------------------------------------------------------;
  15. data    segment    word public                ;
  16.     extrn    WBuff        : byte            ; Åæì₧é▌âoâbâtâ@
  17.     extrn    CrcTable    : word            ; éâéÆéâùpâeü[âuâï
  18.     extrn    CRC        : word            ; éâéÆéâ
  19.     extrn    DicSeg        : word            ; Ä½Åæâoâbâtâ@
  20.                             ;
  21.         SrcSeg        dw    ?        ;
  22.         WPoint        dw    ?        ; Åæì₧é▌â|âCâôâ^
  23.         InHandle    dw    ?        ; ôⁿù═ânâôâhâï
  24.         OutHandle    dw    ?        ; Åoù═ânâôâhâï
  25.         PushSp        dw    ?        ; éôéÉæ▐ö≡ùpâÅü[âN
  26.         SrcSize        dw    ?        ; âtâ@âCâïâTâCâY
  27.         DicSize        dw    ?        ;
  28.         CodeBuf        db    33 dup(?)    ; éWârâbâgùpâÅü[âN
  29.         CmpLen        dw    ?        ;
  30.         SBufLen        dw    ?        ;
  31.         CPoint        dw    ?        ;
  32.         SftFlg        db    ?        ;
  33.         MatchLen    dw    ?        ;
  34.         MatchAdr    dw    ?        ;
  35.         BCD        dw    ?        ;
  36.         BCD2        dw    ?        ;
  37.         BCDSTR        db    14 dup(?)    ;
  38.                             ;
  39.         MINWORD        equ    3        ;
  40.         MAXWORD        equ    0ffffh        ;
  41. data    ends                        ;
  42.                             ;
  43. code    segment    byte public                ;
  44.     assume    cs:code,ds:data,es:data            ;
  45.                             ;
  46.     public        EnCode16            ;
  47.                             ;
  48.     WBUFFEND    equ    0fffh            ;
  49.                             ;
  50. ;-------------------------------------------------------;
  51. ; ïñÆ╩âîâWâXâ^ò╧Éö                    ;
  52. ; ----------------                    ;
  53. ;    ds:[si]        â\ü[âXâ|âCâôâ^            ;
  54. ;-------------------------------------------------------;
  55. BEGIN    CodeFlush                    ;
  56.     mov    cx,CPoint                ;
  57.     mov    bx,offset CodeBuf            ;
  58.     sub    cx,bx                    ;
  59.     mov    di,WPoint                ;
  60.     .do                        ;
  61.         mov    al,[bx]                ;
  62.         inc    bx                ;
  63.         .if    <di a WBUFFEND>            ;
  64.             pushm    ax,bx,cx        ;
  65.             mov    dx,offset WBuff        ;
  66.             mov    cx,di            ;
  67.             mov    bx,OutHandle        ;
  68.             msdos    40h            ;
  69.             jc    ErrOut            ;
  70.             cmp    ax,cx            ;
  71.             jne    ErrOut            ;
  72.             popm    cx,bx,ax        ;
  73.             xor    di,di            ;
  74.         .endif                    ;
  75.         mov    WBuff[di],al            ;
  76.         inc    di                ;
  77.     .loop                        ;
  78.     mov    WPoint,di                ;
  79.     mov    SftFlg,1                ;
  80.     mov    CodeBuf,0                ;
  81.     mov    CPoint,(offset CodeBuf)+1        ;
  82.     ret                        ;
  83. ENDN    CodeFlush                    ;
  84. ;-------------------------------------------------------;
  85. ; âfü[â^Åoù═                        ;
  86. ; ----------                        ;
  87. ;    in    cx    ôKìçÆ╖                ;
  88. ;    des    --                    ;
  89. ;-------------------------------------------------------;
  90. BEGIN    OutPut                        ;
  91.     push    cx                    ;
  92.     dec    cx                    ;
  93.     mov    bx,CPoint                ;
  94.     .if    <z>                    ;
  95.         push    ds                ;
  96.         mov    ds,SrcSeg            ;
  97.         mov    al,[si]                ;
  98.         pop    ds                ;
  99.         mov    [bx],al                ;
  100.         inc    bx                ;
  101.         mov    al,SftFlg            ;
  102.         or    CodeBuf,al            ;
  103.     .else                        ;
  104.         sub    cx,3                ;
  105.         mov    ax,MatchAdr            ;
  106.         mov    [bx],ax                ;
  107.         inc    bx                ;
  108.         inc    bx                ;
  109.         mov    [bx],cx                ;
  110.         inc    bx                ;
  111.         inc    bx                ;
  112.     .endif                        ;
  113.     mov    CPoint,bx                ;
  114.     shl    SftFlg,1                ;
  115.     .if    <c>                    ;
  116.         call    CodeFlush            ;
  117.     .endif                        ;
  118.     pop    cx                    ;
  119.     ret                        ;
  120. ENDN    OutPut                        ;
  121. ;-------------------------------------------------------;
  122. ; ébéqébîvÄZ                        ;
  123. ; ----------                        ;
  124. ;    in    cx,dx                    ;
  125. ;    out    --                    ;
  126. ;    des    --                    ;
  127. ;-------------------------------------------------------;
  128. BEGIN    CrcCalc                        ;
  129.     .if    <cxnz>                    ;
  130.         pushm    es,si,dx,cx,bx,ax        ;
  131.         mov    es,SrcSeg            ;
  132.         mov    si,dx                ;
  133.         mov    dx,CRC                ;
  134.         .do                    ;
  135.             mov    al,es:[si]        ;
  136.             inc    si            ;
  137.             mov    bl,dl            ;
  138.             xor    bh,bh            ;
  139.             xor    bl,al            ;
  140.             shl    bx,1            ;
  141.             mov    ax,CrcTable[bx]        ;
  142.             mov    bl,dh            ;
  143.             xor    bh,bh            ;
  144.             xor    bx,ax            ;
  145.             mov    dx,bx            ;
  146.         .loop                    ;
  147.         mov    CRC,dx                ;
  148.         popm    ax,bx,cx,dx,si,es        ;
  149.     .endif                        ;
  150.     ret                        ;
  151. ENDN    CrcCalc                        ;
  152. ;-------------------------------------------------------;
  153. ; âfü[â^ô╟é▌ì₧é▌                    ;
  154. ; --------------                    ;
  155. ;    in    cx                    ;
  156. ;-------------------------------------------------------;
  157. BEGIN    ReSetBuf                    ;
  158.     add    si,cx                    ;
  159.     sub    SBufLen,cx                ;
  160.     mov    ax,SBufLen                ;
  161.     .if    <ax b CmpLen>                ;
  162.         mov    CmpLen,ax            ;
  163.     .endif                        ;
  164.       ret                        ;
  165. ENDN    ReSetBuf                    ;
  166. ;-------------------------------------------------------;
  167. ; îƒì⌡   SI  -->  CX
  168. ;-------------------------------------------------------;
  169. BEGIN    Search                        ;
  170.     mov    es,DicSeg                ;
  171.     xor    di,di                    ;
  172.     mov    MatchLen,MINWORD            ;
  173.     .if    <CmpLen be MINWORD>            ;
  174.         jmp    #out                ;
  175.     .endif                        ;
  176.     mov    cx,DicSize                ;
  177.     .do                        ;
  178.         push    ds                ;
  179.         mov    ds,SrcSeg            ;
  180.         mov    al,[si]                ;
  181.         pop    ds                ;
  182.         .do                    ;
  183.             .if    <cx be MINWORD>        ;
  184.                 jmp    #out        ;
  185.             .endif                ;
  186.             or    cx,cx            ;
  187.             repnz    scasb            ;
  188.         .enddo    <nz>                ;
  189.         .break    <cx be MatchLen>        ;
  190.         pushm    cx,si,di            ;
  191.         inc    cx                ;
  192.         .if    <cx a CmpLen>            ;
  193.             mov    cx,CmpLen        ;
  194.         .endif                    ;
  195.         dec    di                ;
  196.         mov    dx,di                ;
  197.         mov    bx,cx                ;
  198.         xor    al,al                ;
  199.         push    ds                ;
  200.         mov    ds,SrcSeg            ;
  201.         repz    cmpsb                ;
  202.         pop    ds                ;
  203.         .if    <z>                ;
  204.             popm    di,si,ax        ;
  205.             mov    MatchLen,bx        ;
  206.             mov    MatchAdr,dx        ;
  207.             .break                ;
  208.         .endif                    ;
  209.         sub    bx,cx                ;
  210.         dec    bx                ;
  211.         .if    <bx a MatchLen>            ;
  212.             mov    MatchLen,bx        ;
  213.             mov    MatchAdr,dx        ;
  214.         .endif                    ;
  215.         popm    di,si,cx            ;
  216.     .enddo    <>                    ;
  217. #out:    mov    cx,MatchLen                ;
  218.     .if    <cx be MINWORD>                ;
  219.         mov    cx,1                ;
  220.     .endif                        ;
  221.     ret                        ;
  222. ENDN    Search                        ;
  223. ;-------------------------------------------------------;
  224. ; âJâEâôâgò\Ī CX
  225. ;-------------------------------------------------------;
  226. BEGIN    Display                        ;
  227.     push    cx                    ;
  228.     .if    <cx e 1>                ;
  229.         mov    ax,BCD                ;
  230.         inc    al                ;
  231.         daa                    ;
  232.         xchg    ah,al                ;
  233.         adc    al,0                ;
  234.         daa                    ;
  235.         xchg    ah,al                ;
  236.         mov    BCD,ax                ;
  237.         and    ax,0f0fh            ;
  238.         or    ax,3030h            ;
  239.         mov    BCDSTR[3],ah            ;
  240.         mov    BCDSTR[5],al            ;
  241.         mov    ax,BCD                ;
  242.         mov    cl,4                ;
  243.         shr    ax,cl                ;
  244.         and    ax,0f0fh            ;
  245.         or    ax,3030h            ;
  246.         mov    BCDSTR[2],ah            ;
  247.         mov    BCDSTR[4],al            ;
  248.     .else                        ;
  249.         mov    ax,BCD2                ;
  250.         inc    al                ;
  251.         daa                    ;
  252.         xchg    ah,al                ;
  253.         adc    al,0                ;
  254.         daa                    ;
  255.         xchg    ah,al                ;
  256.         mov    BCD2,ax                ;
  257.         and    ax,0f0fh            ;
  258.         or    ax,3030h            ;
  259.         mov    BCDSTR[10],ah            ;
  260.         mov    BCDSTR[12],al            ;
  261.         mov    ax,BCD2                ;
  262.         mov    cl,4                ;
  263.         shr    ax,cl                ;
  264.         and    ax,0f0fh            ;
  265.         or    ax,3030h            ;
  266.         mov    BCDSTR[9],ah            ;
  267.         mov    BCDSTR[11],al            ;
  268.     .endif                        ;
  269.     mov    bx,2                    ;
  270.     mov    cx,14                    ;
  271.     mov    dx,offset BCDSTR            ;
  272.     msdos    40h                    ;
  273.     pop    cx                    ;
  274.     ret                        ;
  275. ENDN    Display                        ;
  276. ;-------------------------------------------------------;
  277. ; Åëè·ë╗              --> SI
  278. ;-------------------------------------------------------;
  279. BEGIN    Init                        ;
  280.     mov    BCD,1                    ;
  281.     mov    BCD2,1                    ;
  282.     mov    BCDSTR,CR                ;
  283.     mov    BCDSTR[1],'('                ;
  284.     mov    BCDSTR[2],'0'                ;
  285.     mov    BCDSTR[3],'0'                ;
  286.     mov    BCDSTR[4],'0'                ;
  287.     mov    BCDSTR[5],'0'                ;
  288.     mov    BCDSTR[6],')'                ;
  289.     mov    BCDSTR[7],'-'                ;
  290.     mov    BCDSTR[8],'('                ;
  291.     mov    BCDSTR[9],'0'                ;
  292.     mov    BCDSTR[10],'0'                ;
  293.     mov    BCDSTR[11],'0'                ;
  294.     mov    BCDSTR[12],'0'                ;
  295.     mov    BCDSTR[13],')'                ;
  296. ;-------------------------------------------------------;
  297.     movdat    SrcSeg,DicSeg                ;
  298.     add    SrcSeg,1000h                ;
  299.     .if    <DicSize b MAXWORD>            ;
  300.         movdat    CmpLen,DicSize            ;
  301.     .else                        ;
  302.         mov    CmpLen,MAXWORD            ;
  303.     .endif                        ;
  304.     movdat    SBufLen,SrcSize                ;
  305. ;-------------------------------------------------------;
  306.     mov    cx,SrcSize                ;
  307.     mov    bx,InHandle                ;
  308.     xor    dx,dx                    ;
  309.     push    ds                    ;
  310.     mov    ds,SrcSeg                ;
  311.     msdos    3fh                    ;
  312.     pop    ds                    ;
  313.     jc    ErrOut                    ;
  314.     cmp    ax,cx                    ;
  315.     jne    ErrOut                    ;
  316.     call    CrcCalc                    ;
  317.     mov    ax,SBufLen                ;
  318.     .if    <ax b CmpLen>                ;
  319.         mov    CmpLen,ax            ;
  320.     .endif                        ;
  321. ;-------------------------------------------------------;
  322.     mov    SftFlg,1                ;
  323.     mov    CodeBuf,0                ;
  324.     mov    CPoint,(offset CodeBuf)+1        ;
  325.     mov    WPoint,0                ;
  326.     xor    si,si                    ;
  327.     ret                        ;
  328.     ret                        ;
  329. ENDN    Init                        ;
  330. ;-----------------------------------------------------------------------------;
  331. ; EnCode64(in:word,out:word;dicsize,size:longint):boolean              ;
  332. ;-----------------------------------------------------------------------------;
  333. BEGIN    EnCode16                    ;
  334.     cld                        ;
  335.     mov